local M = _G.ClientOHOH.class.new(script,_G.ClientOHOH.files.Client_PlayerComponent(),script.Parent.Name)
local ClientOHOH = _G.ClientOHOH
local AFKGui = ClientOHOH.load.UIManager():CreateUI("AFKGui",require(script.AFKGui))
local CallBackManager = ClientOHOH.load.CallBackManager();
local UIManager = ClientOHOH.load.UIManager();
local Good_Cfg=ClientOHOH.config.Goods
local EventList = ClientOHOH.load.EventList();
local FunctionList = ClientOHOH.load.FunctionList();
local GroupReward_cfg = ClientOHOH.config.GroupReward_data
local afk_cfg =require(script.Parent.cfg)
function M.new(self,...)
    return M(self,...)
end

function M.ctor(self,parent)
    M.super.ctor(self,parent)
    self.DataStore = self.parent:GetComponent(_G.ClientOHOH.load.Client_PlayerDataComponent())
    self.player = parent
    local gamepass = self.DataStore:GetData("gamePass")
    if gamepass["VIP"] then
        self.IsBuyVIP = true
    end
    self:AddConnect()
    self.AFKObjList={}
    for _,v in pairs(afk_cfg) do
        self.AFKObjList[v.id]=require(script.Parent:FindFirstChild(v.class)).new(self.player,v.titleId,v.value, self.DataStore)
    end

    AFKGui:FullData(self.AFKObjList)
end

function M.AddConnect(self)
	local AFK=ClientOHOH:GetPath_Loop("AFK",game.Workspace.Touch)
	AFK.ChildAdded:Connect(function(child)

		local touchPart = child
		CallBackManager:AddRbxConnect(self,touchPart.Touched, function(obj,chPart)
			if not _G.CommonOHOH.load.GeneralTool().IsMeTouchEvent(chPart,"LeftLowerLeg") then
				return 
			end
			AFKGui:Show()
            self.player.InAFKEvent:Action()
            self:Invoke(FunctionList.inform_afk,true)
		end);
	
		CallBackManager:AddRbxConnect(self,touchPart.TouchEnded, function(obj,chPart)
			if not _G.CommonOHOH.load.GeneralTool().IsMeTouchEvent(chPart,"LeftLowerLeg")  then
				return 
			end
            AFKGui:Hide()
            self.player.OutAFKEvent:Action()
            self:Invoke(FunctionList.inform_afk,false)
		end);
	end)

    self.player.UserDataEvent:Connect(function(data)
        if data["gamePass"] then
            if data["gamePass"]["VIP"] then
                self.IsBuyVIP = true
            end
        end
    end)
    
end

function M.dtor(self)
    M.super.dtor(self)
end


return M 